import Vue from 'vue'
import App from './App'
import store from './store'
Vue.prototype.$store = store
Vue.prototype.$loginUrl = 'http://sso-xiaoyitong.gzaojun.com';
import uView from "uview-ui"
import './iconfont/iconfont.css'
import customTabbar from './components/custom-tabbar.vue'
Vue.use(uView);
Vue.config.productionTip = false;
//挂载在vue下面的组件需要写在Vue.config.productionTip的下面否者会报错
Vue.component('custom-tabbar', customTabbar);
//页面跳转
Vue.prototype.$baseUrl = uni.getStorageSync('host');
Vue.prototype.$toLink = (link, obj, type = 0) => {
	if (obj && obj != {}) {
		let option = [];
		for (let i in obj) {
			if (typeof(obj[i]) == 'object') {
				option.push(i + '=' + JSON.stringify(obj[i]))
			} else {
				option.push(i + '=' + obj[i])
			}
		}
		option = option.join('&');
		link = link + "?" + option;
	}
	//跳至tab页面
	if (type == 3) {
		uni.switchTab({
			url: link
		})
	} else if (type == 2) {
		uni.redirectTo({
			url: link,
			animationType: 'pop-in',
			animationDuration: 300,
		})
	} else if (type == 1) {
		uni.reLaunch({
			url: link,
		})
	} else {
		uni.navigateTo({
			url: link,
		})
	}
}
Vue.prototype.$format = (date, index) => {
	let time = date;
	let arr = time.split('-');
	let arrLength = arr.length;
	let str = '';
	switch (index) {
		case 1:
			str = arr.slice(0, arrLength - 1).join('.');
			break;
		case 2:
			str = arr.slice(arrLength - 1, arrLength).join('').substr(0, 5);
			break;
	}
	return str;
}
Vue.prototype.$width = param => {
	let str = '';
	switch (param) {
		case '报修管理':
			str = '44rpx';
			break;
		case '我的课组':
			str = '50rpx';
			break;
		case '社团报名':
			str = '50rpx';
			break;
		case '学校通知':
			str = '48rpx';
			break;
		case '学生请假':
			str = '50rpx';
			break;
		default:
			str = '54rpx';
	}
	return str;

}
Vue.prototype.$classify = (param, index) => {
	let str = '';
	if (index == 1) {
		switch (param) {
			case 1:
				str = '#FFA100';
				break;
			case 2:
				str = '#48DBC3';
				break;
			case 3:
				str = '#FFA100';
				break;
		}

	} else if (index == 2) {
		switch (param) {
			case 1:
				str = '待审核';
				break;
			case 2:
				str = '通过';
				break;
			case 3:
				str = '不通过';
				break;
		}
	} else {
		switch (param) {
			case 1:
				str = '去处理';
				break;
			case 2:
				str = '通过';
				break;
			case 3:
				str = '不通过';
				break;
		}
	}
	return str;
}
Vue.prototype.$gender = (param, index) => {
	let str = '';
	switch (index) {
		case 1:
			if (param == 1) {
				str = '男';
			} else {
				str = '女';
			}
			break;
		case 2:
			if (param == 1) {
				str = '../../static/tupian118.png';
			} else {
				str = '../../static/tupian119.png';
			}
			break;
	}
	return str;
}
Vue.prototype.$picture = param => {
	let str = '';
	switch (param) {
		case 0:
			str = '../../static/tupian99.png';
			break;
		case 1:
			str = '../../static/tupian98.png';
			break;
		case 2:
			str = '../../static/tupian98.png';
			break;
	}
	return str;
}
Vue.prototype.$classroom = (param) => {
	let str = '';
	switch (param) {
		case 1:
			str = '功能室';
			break;
		case 2:
			str = '会议室';
			break;
		case 3:
			str = '实验室';
			break;
	}
	return str;
}
Vue.prototype.$status = (param, index) => {
	let str = '';
	if (index == 1) {
		switch (param) {
			case 1:
				str = '待审核';
				break;
			case 2:
				str = '已通过';
				break;
			case 3:
				str = '未通过';
				break;
		}
	} else if (index == 2) {
		switch (param) {
			case 1:
				str = '#f8b551';
				break;
			case 2:
				str = '#3ebd13';
				break;
			case 3:
				str = '#ec654e';
				break;
		}
	} else if (index == 3) {
		switch (param) {
			case 1:
				str = '去审核';
				break;
			case 2:
				str = '';
				break;
			case 3:
				str = '';
				break;
		}
	} else {
		switch (param) {
			case 1:
				str = '#f8b551';
				break;
			case 2:
				str = '#fff';
				break;
			case 3:
				str = '#fff';
				break;
		}
	}
	return str;
}
Vue.prototype.$toggleIcon = (param) => {
	let str = '';
	switch (param) {
		case '全校':
			str = '../../static/tupian82.png';
			break;
		case '年级':
			str = '../../static/tupian147.png';
			break;
		case '班级':
			str = '../../static/tupian83.png';
			break;
	}
	return str;
}

App.mpType = 'app'

const app = new Vue({
	...App,
	store

})
app.$mount()
